<template>
  <div class="second">
    <div class="second-header">
      <van-icon name="arrow-left" size="27px" color="#777" @click="changeToback" />
      <b>我的二手房</b>
      <span @click="goOut">发布</span>
    </div>
    <div class="second-main">
      <dl v-for="(item, index) in List" :key="index">
        <dt>
          <img :src="item.img" alt />
        </dt>
        <dd>
          <p>标题:{{ item.listingTitle }}</p>
          <p>售价:{{ item.sellingprice }}元/m²</p>
          <p>特色:{{ item.Speciallabel }}</p>
          <p>
            <span>{{item.stateType}}</span>
            <span @click="handleDel(item.id)">删除</span>
          </p>
        </dd>
      </dl>
    </div>
  </div>
</template>
<script>
import { getRecommend } from "@/api";
import { getDelete } from "@/api";
export default {
  data() {
    return {
      List: []
    };
  },
  created() {
    this.getRecommend();
  },
  methods: {
    getRecommend() {
      getRecommend({ classifyType: 2 }).then(res => {
        console.log(res);
        this.List = res.data.data.res;
      });
    },
    goOut() {
      this.$router.push("/publish");
    },
    handleDel(id) {
      getDelete(id).then(res => {
        console.log(res);
        this.getRecommend();
      });
    },
    changeToback() {
      //返回上一级
      this.$router.go(-1);
    }
  }
};
</script>
<style scoped>
.second {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.second-header {
  width: 100%;
  height: 40px;
  line-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #ccc;
  padding-right: 15px;
}
.second-main {
  flex: 1;
  overflow-y: scroll;
}
dl{
  display: flex;
  margin-top: 20px;
}
dl>dd>p{
  margin: 2px 0;
}
dl>dd>p>span{
  display: inline-block;
  border: 1px solid #ccc;
  padding: 3px;
  margin: 0 5px;
}
</style>